<!DOCTYPE html>
<html>
<head>
<#include "/common/freemarker/include_css.ftl">
<title>编辑</title>
</head>
 
<body>
	<div class="panel panel-default">
	   <div class="panel-heading">
	       <div class="panel-title">编辑</div>
	   </div>
	   <div clas="panel-body">
	      <div class="row">
	           <div class="col-md-12">
	               <br>
	               <form id="contentForm" class="form-horizontal"  action="<@context/>ued/tpltb3uuid/save.do" method="post"  >
	                	<input type="hidden" name="uuid" value='<#if obj?exists>${obj.uuid?if_exists}</#if>' />
						<input type="hidden" name="projectId" value='<#if obj?exists>${obj.projectId?if_exists}</#if>' />
	                    <div class="form-group">
	                    	<label class="col-md-2 control-label">标题 <font color="red"> *</font></label>
	                        <div class="col-md-9">
								<input type="text"  class="input-sm form-control required" id="title" name="title" value='<#if obj?exists>${obj.title?if_exists}</#if>'    minlength="2"  />
	                    	</div>              	
	                    </div> 
	                     <div class="form-group">
	                    	<label class="col-md-2 control-label">完成期限 <font color="red"> *</font></label>
	                        <div class="col-md-9">
	                   			<input type="text" class="input-sm form-control required" readonly id="deadline" name="deadline" value='<#if obj?exists && obj.deadline?exists>${obj.deadline?string("yyyy-MM-dd HH:mm:ss")}</#if> ' 
								onclick="javascript:WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'});"   class="{required:true}"/>
						     </div>              	
	                    </div>
 	                    <div class="form-group">
	                    	<label class="col-md-2 control-label">性别<font color="red"> *</font></label>
	                        <div class="col-md-9">
	                    		<div>
	                    			 
								      <label><input  class="required" type="radio" name="sex" id="sex_1"  value="男"    label="男" <#if obj?exists && obj.sex?default("")=="男">checked</#if>   />男</label>
						      		  &nbsp;&nbsp;&nbsp;&nbsp;
								      <label><input class="required" type="radio" name="sex" id="sex_0"  value="女"    label="女" <#if obj?exists && obj.sex?default("")=="女">checked</#if>  />女</label>
								     
								</div>  
 	
	                    	</div>              	
	                    </div> 
 	                    <div class="form-group">
	                    	<label class="col-md-2 control-label">兴趣爱好<font color="red"> *</font></label>
	                        <div class="col-md-9">
	                    		<div>
		                    		  
									      <label><input class="required" type="checkbox" name="hobbyChk" id="hobby_1"  value="下棋"    label="下棋" <#if (obj?exists && obj.hobby?default("")?index_of("下棋")!=-1)>checked</#if>   /> 下棋</label>
							      		  &nbsp;&nbsp;&nbsp;&nbsp;
									      <label><input class="required" type="checkbox" name="hobbyChk" id="hobby_2"  value="游泳"    label="游泳" <#if (obj?exists && obj.hobby?default("")?index_of("游泳")!=-1)>checked</#if>  /> 游泳</label>
									    
								      
								      <input type="hidden" name="hobby" id="hobby" value="<#if obj?exists>${obj.hobby?if_exists}</#if>"/>
								      
 
	        								      
								</div>  
 		
	                    	</div>              	
	                    </div> 
	                    <div class="form-group">
	                    	<label class="col-md-2 control-label">附件</label>
	                        <div class="col-md-9">
	                            <#assign tmps="">
	                        	<#if obj?exists>
									<#assign tmps=obj.attachment?if_exists>
	                        	</#if>
	                   			 <@attachment  id="attachment" name="attachment" value="${tmps}" namePrefix=""  showType="all" /> 
						     </div>              	
	                    </div>  
	                    <div class="form-group">
	                    	<div class="col-md-offset-2 col-md-10">
	                    		<input type="button" class="btn btn-sm btn-primary" id="submitBtn" value="保 存"/>
	                    		<input type="button" class="btn btn-sm btn-default" value="返 回" onclick="javascript:history.go(-1)"/>
	                    	</div>
	                    </div>
	              </form>
	        </div>
	    </div>
	</div>
	<#--  公共js -->
	<#include "/common/freemarker/include_js.ftl">
	<#--  页面自己的js -->
	
	<script>
	
		 $(document).ready(function(){
		 	    <#--
		 	    var form = $('#contentForm');
		  		form.validate({
					rules: {
		    			"sex":{
			    			required: true,
		    			}
					}
			    });
			   	--> 
			    
			  $('input[name="sex"]').iCheck({
			 	  checkboxClass : 'icheckbox_square-blue', 
				  radioClass : 'iradio_square-blue', 
				  increaseArea : '20%' 
			  });
			  $('input[name="hobbyChk"]').iCheck({
			 	  checkboxClass : 'icheckbox_square-blue', 
				  radioClass : 'iradio_square-blue', 
				  increaseArea : '20%' 
			  });			  
			  
			  $('input[name="sex"]').on('ifChecked', function(event){  
			       alert($(this).val() + ' selected');  
			  }); 			  
		});
		
 
		
		$("#submitBtn").click(function() {
			  if(!$("#contentForm").valid()){
			    	 return;
			  }
			  
			  
			  	var hobbies="";
			    $('input[name="hobbyChk"]').each(function() {
				        if ($(this).prop('checked') ==true) {
				        	if (hobbies==""){
				        		hobbies=$(this).val();
				        	}else{
				        		hobbies=hobbies+","+$(this).val();
				        	}
				        }
				});
		 
			  document.getElementById("hobby").value=hobbies;
 
			  	  
			  	  
			  $("#submitBtn").attr("value", "提交中..."); 
			  $('#contentForm').find(":button").attr("disabled", true);
			  $("#contentForm").submit(); //提交表单，如果不写，即便通过表单也不会自动提交 
		})
		 

	
	</script>
</body>
</html>
 

